<?php
apf_require_controller("QaAbstract");
apf_require_class('Tools_Uploader');
class Qa_Image_UploadController extends QaAbstractController {
    public function handle_request() {

        if($_FILES['imgFile']['name']) {
            $upDir = 'upload/qa/wd';
            $uploader = new Tools_Uploader('imgFile');
            $uploader->setValidExt(array(
                    '.jpg',
                    '.jpeg',
                    '.gif',
                    '.bmp',
                    '.png',
            ));
            $uploader->setUpDir(CODE_PATH . $upDir); // 需修改为你自己的路径
            if ($uploader->upload()) {
                $img = $uploader->getFileName();
                echo json_encode(array('error' => 0, 'url' => Util_BaseUrls::qa_image_url($img)));
            } else {
                echo json_encode(array('error' => 1, 'message' => $uploader->getErrorMsg()));
            }
            exit;
        }else{

        }
    }
}

